<template>
  <div>
    <el-container>
      <el-header>
        <img
          :src="QFlogo"
          height="60px"
          style="width:200px;display:block;float:left;margin-left:-20px"
        >
        <h1 style="width:200px;float:left;margin-left:230px;">千峰教育管理系统</h1>
        <el-col :span="8" class="right">
          <div class="grid-content login">
            <span>欢迎您</span>
            <a href="javascript:;" style="text-decoration:none">-^_^-{{nickname}}</a>
            <a href="javascript:;" style="margin-left:20px" @click="quit">退出登入</a>
          </div>
        </el-col>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-radio-group v-model="isCollapse" style="margin-bottom: 20px;">
            <el-radio-button :label="false">展开</el-radio-button>
            <el-radio-button :label="true">收起</el-radio-button>
          </el-radio-group>
          <el-menu
            default-active="1-4-1"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
            :collapse="isCollapse"
            :router="true"
          >
            <el-submenu index="1">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span slot="title">项目管理</span>
              </template>
              <el-menu-item index="student" class="student">
                <i class="el-icon-video-pause"></i>
                学员项目管理
              </el-menu-item>
            </el-submenu>
            <el-menu-item index="2">
              <i class="el-icon-menu"></i>
              <span slot="title">导航二</span>
            </el-menu-item>
            <el-menu-item index="3">
              <i class="el-icon-document"></i>
              <span slot="title">导航三</span>
            </el-menu-item>
            <el-menu-item index="4">
              <i class="el-icon-setting"></i>
              <span slot="title">导航四</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import QFlogo from "@/assets/images/qf.jpg";
import { verify } from "@/api";
export default {
  data() {
    return {
      isCollapse: true,
      QFlogo,
      nickname:""
    };
  },
  mounted() {
    let _this = this;
    verify().then(res => {
      if (!res.data.state) {
        _this.$router.push("/login");
      }
    });
   let nickname = localStorage.getItem("nickname")
   _this.nickname = nickname
  },
  methods: {
    handleOpen() {
      // console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      // console.log(key, keyPath);
    },
    quit() {
      localStorage.removeItem("token");
      localStorage.removeItem("nickname");
      this.$router.push("/login");
    }
  }
};
</script>

<style>
.el-header,
.el-footer {
  min-width: 50px;
  background-color: #b3c0d1;
  color: rgb(253, 253, 253);
  /* text-align: center; */
  line-height: 60px;
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
.el-col.right {
  /* padding-right: 0 !important; */
  /* text-align: right; */
  float: left;
}
.grid-content.login a {
  color: rgb(9, 54, 59);
}
</style>
